<template>
  <div class="profile-posts">
    <!-- 背景渐变 -->
    <div class="background-gradient"></div>
    
    <!-- 头像背景椭圆 -->
    <div class="avatar-background"></div>
    
    <!-- iOS状态栏 -->
    <div class="status-bar">
      <div class="left-side">
        <span class="time">9:41</span>
      </div>
      <div class="notch">
        <img src="@/assets/images/profile-ui/notch-white.svg" alt="notch" class="notch-icon" />
      </div>
      <div class="right-side">
        <div class="signal-icons">
          <div class="mobile-signal"></div>
          <div class="wifi-signal"></div>
          <div class="battery">
            <div class="battery-level"></div>
          </div>
        </div>
      </div>
    </div>

    <!-- 页面头部 -->
    <div class="page-header">
      <span class="logout-text" @click="onLogout">Logout</span>
      <span class="profile-text">Profile</span>
      <span class="settings-text" @click="onSettings">Settings</span>
    </div>

    <!-- 用户头像 -->
    <div class="user-avatar">
      <img src="@/assets/images/profile-ui/profile-avatar.png" alt="Victoria Robertson" class="avatar-image" />
    </div>

    <!-- 用户信息 -->
    <div class="user-info">
      <div class="user-name">Victoria Robertson</div>
      <div class="user-bio">A mantra goes here</div>
    </div>

    <!-- 分段控制器 -->
    <div class="segmented-control">
      <div class="control-background">
        <div class="selected-tab" :style="{ transform: `translateX(${theSelectedIndex * 100}%)` }"></div>
        <div 
          class="tab-item" 
          :class="{ active: theSelectedIndex === 0 }"
          @click="onSelectTab(0)"
        >
          Posts
        </div>
        <div 
          class="tab-item" 
          :class="{ active: theSelectedIndex === 1 }"
          @click="onSelectTab(1)"
        >
          Photos
        </div>
        <div 
          class="tab-item" 
          :class="{ active: theSelectedIndex === 2 }"
          @click="onSelectTab(2)"
        >
          Search
        </div>
      </div>
    </div>

    <!-- 内容区域 -->
    <div class="content-area">
      <div 
        v-for="(post, index) in thePosts" 
        :key="index"
        class="content-block"
      >
        <div class="content-header">
          <span class="header-title">Header</span>
          <span class="post-time">8m ago</span>
        </div>
        <div class="content-text">
          {{ post.content }}
        </div>
        <div class="divider-line"></div>
      </div>
    </div>

    <!-- 底部导航栏 -->
    <div class="bottom-bar">
      <div class="bar-background">
        <div class="home-indicator"></div>
        <div class="tabs-container">
          <div 
            v-for="(tab, index) in theTabs" 
            :key="index"
            class="tab-dot"
            :class="{ active: index === 0 }"
            @click="onTabClick(index)"
          ></div>
        </div>
        <div class="top-divider"></div>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref } from 'vue'

// 分段控制器数据 start
const theSelectedIndex = ref(0)

const onSelectTab = (index: number) => {
  theSelectedIndex.value = index
}
// 分段控制器数据 end

// 帖子数据 start
const thePosts = ref([
  {
    content: "He'll want to use your yacht, and I don't want this thing smelling like fish."
  },
  {
    content: "He'll want to use your yacht, and I don't want this thing smelling like fish."
  },
  {
    content: "He'll want to use your yacht, and I don't want this thing smelling like fish."
  },
  {
    content: "He'll want to use your yacht, and I don't want this thing smelling like fish."
  }
])
// 帖子数据 end

// 底部导航数据 start
const theTabs = ref([1, 2, 3, 4, 5])

const onTabClick = (index: number) => {
  console.log('点击底部导航:', index)
}
// 底部导航数据 end

// 退出登录
const onLogout = () => {
  console.log('退出登录')
}

// 设置页面
const onSettings = () => {
  console.log('打开设置')
}
</script>

<style lang="scss" scoped>
.profile-posts {
  width: 375px;
  height: 812px;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  .background-gradient {
    position: absolute;
    top: 0;
    left: -1px;
    width: 376px;
    height: 245px;
    background: #5DB075;
    z-index: 1;
  }
  
  .avatar-background {
    position: absolute;
    top: 128px;
    left: 108px;
    width: 158px;
    height: 158px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 50%;
    z-index: 2;
  }
  
  .status-bar {
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: relative;
    z-index: 10;
    
    .left-side {
      .time {
        font-size: 15px;
        font-weight: 600;
        color: #ffffff;
        letter-spacing: -0.3px;
      }
    }
    
    .notch {
      position: absolute;
      top: -2px;
      left: 78px;
      
      .notch-icon {
        width: 219px;
        height: 30px;
      }
    }
    
    .right-side {
      .signal-icons {
        display: flex;
        align-items: center;
        gap: 5px;
        
        .mobile-signal {
          width: 17px;
          height: 10px;
          background: linear-gradient(to right, 
            #fff 0%, #fff 25%, 
            #fff 25%, #fff 50%, 
            #fff 50%, #fff 75%, 
            #fff 75%, #fff 100%);
          border-radius: 1px;
        }
        
        .wifi-signal {
          width: 15px;
          height: 11px;
          background: #fff;
          border-radius: 1px;
          position: relative;
          
          &::before {
            content: '';
            position: absolute;
            width: 100%;
            height: 100%;
            background: radial-gradient(circle at bottom, transparent 40%, #fff 41%);
          }
        }
        
        .battery {
          width: 24px;
          height: 11px;
          border: 1px solid rgba(255, 255, 255, 0.35);
          border-radius: 2.5px;
          position: relative;
          
          &::after {
            content: '';
            position: absolute;
            right: -3px;
            top: 3px;
            width: 1px;
            height: 4px;
            background: rgba(255, 255, 255, 0.4);
            border-radius: 0 1px 1px 0;
          }
          
          .battery-level {
            width: 18px;
            height: 7px;
            background: #fff;
            border-radius: 1px;
            margin: 1px;
          }
        }
      }
    }
  }
  
  .page-header {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: relative;
    z-index: 10;
    
    .logout-text {
      font-size: 17px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
      
      &:hover {
        opacity: 0.7;
      }
    }
    
    .profile-text {
      font-size: 17px;
      font-weight: 600;
      color: #ffffff;
      letter-spacing: -0.4px;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
    }
    
    .settings-text {
      font-size: 17px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
      
      &:hover {
        opacity: 0.7;
      }
    }
  }
  
  .user-avatar {
    position: absolute;
    top: 128px;
    left: 108px;
    width: 158px;
    height: 158px;
    z-index: 15;
    
    .avatar-image {
      width: 100%;
      height: 100%;
      border-radius: 50%;
      border: 4px solid #ffffff;
      object-fit: cover;
      box-shadow: 0px 4px 20px 0px rgba(101, 101, 101, 0.15);
    }
  }
  
  .user-info {
    position: absolute;
    top: 306px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 10;
    
    .user-name {
      font-size: 17px;
      font-weight: 600;
      color: #000000;
      letter-spacing: -0.4px;
      margin-bottom: 4px;
    }
    
    .user-bio {
      font-size: 13px;
      font-weight: 400;
      color: #000000;
      opacity: 0.6;
    }
  }
  
  .segmented-control {
    position: absolute;
    top: 360px;
    left: 20px;
    right: 20px;
    z-index: 10;
    
    .control-background {
      background: #F2F2F7;
      border: 1px solid #E5E5EA;
      border-radius: 100px;
      height: 32px;
      position: relative;
      display: flex;
      
      .selected-tab {
        position: absolute;
        top: 0;
        left: 0;
        width: 33.333%;
        height: 100%;
        background: #ffffff;
        border-radius: 100px;
        transition: transform 0.3s ease;
        z-index: 1;
      }
      
      .tab-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        font-weight: 400;
        color: #8E8E93;
        cursor: pointer;
        position: relative;
        z-index: 2;
        transition: color 0.3s ease;
        
        &.active {
          color: #5DB075;
          font-weight: 400;
        }
      }
    }
  }
  
  .content-area {
    position: absolute;
    top: 412px;
    left: 20px;
    right: 20px;
    bottom: 120px;
    z-index: 10;
    overflow-y: auto;
    
    .content-block {
      background: #F2F2F7;
      border-radius: 8px;
      padding: 16px;
      margin-bottom: 12px;
      position: relative;
      
      .content-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        
        .header-title {
          font-size: 15px;
          font-weight: 600;
          color: #000000;
        }
        
        .post-time {
          font-size: 11px;
          font-weight: 400;
          color: #8E8E93;
        }
      }
      
      .content-text {
        font-size: 13px;
        font-weight: 400;
        color: #000000;
        line-height: 1.4;
        margin-bottom: 16px;
      }
      
      .divider-line {
        position: absolute;
        bottom: 0;
        left: 16px;
        right: 16px;
        height: 1px;
        background: #E5E5EA;
      }
    }
  }
  
  .bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    
    .bar-background {
      background: rgba(242, 242, 247, 0.8);
      backdrop-filter: blur(20px);
      padding: 8px 0 34px;
      
      .home-indicator {
        width: 134px;
        height: 5px;
        background: #000000;
        border-radius: 100px;
        margin: 0 auto 21px;
      }
      
      .tabs-container {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-bottom: 8px;
        
        .tab-dot {
          width: 32px;
          height: 32px;
          background: rgba(142, 142, 147, 0.3);
          border-radius: 50%;
          cursor: pointer;
          transition: all 0.3s ease;
          
          &.active {
            background: #5DB075;
          }
          
          &:hover {
            transform: scale(1.1);
          }
        }
      }
      
      .top-divider {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1px;
        background: rgba(60, 60, 67, 0.29);
      }
    }
  }
}

// 响应式适配
@media (max-width: 375px) {
  .profile-posts {
    width: 100vw;
    height: 100vh;
  }
}
</style>